# -*- coding: utf-8 -*-
"""
Created on Sun Sep 18 16:31:05 2016

@author: zhiqiang
"""
#转换为数值编码的数据集合
dics_for_tranf = {'AA': 270.26,
 'AC': 246.23,
 'AG': 286.26,
 'AT': 261.25,
 'CA': 246.23,
 'CC': 222.2,
 'CG': 262.23,
 'CT': 237.22,
 'GA': 286.26,
 'GC': 262.23,
 'GG': 302.26,
 'GT': 277.25,
 'TA': 261.25,
 'TC': 237.22,
 'TG': 277.25,
 'TT': 252.24,
 'II': 252.24,
 'ID': 237.22,
 'DD': 222.2}
gene_Data = []
for key in weiDian:
    temps = result[key]
    temps1 = [dics_for_tranf[gene_dui] for gene_dui in temps]
    gene_Data.append(temps1)
#获取对应编码
    
    
import numpy as np
gene_Data_for_ml = np.array(gene_Data)
gene_Data_for_ml = gene_Data_for_ml.T 

from sklearn.ensemble import RandomForestClassifier
index1 = list(range(400))
index1.extend(list(range(600,1000)))
X=gene_Data_for_ml[index1]
y=np.array(pheno_type_Data)
y=y[index1]
#X=gene_Data_for_ml
#y=pheno_type_Data
randclf = RandomForestClassifier(n_estimators=10)
randclf.fit(X,y)
forpretst = gene_Data_for_ml[list(range(500,600))]
randtree_ans = randclf.predict(X)

from sklearn import cluster
k_means = cluster.KMeans(n_clusters=2)
k_means.fit(gene_Data_for_ml,pheno_type_Data)
ans=k_means.predict(gene_Data_for_ml)

#解析用卡芳检验做出的位点所在的下标
ans_index = getIndex(first_ans)
#获取对应的下标下